package org.forever.util
{
	/**
	* （有向）带权图最小生成树的Prim-Jarnik算法
	*/
	public class BestFSPrim extends BestFS
	{
		public function BestFSPrim(g:Graph)
		{
			super(g);
		}
		
		//更新尚未访问的顶点到已访问集的最短距离
		override protected function updateDistanceAfter(Vertex v):void {
			for (var it:Iterator = v.outEdges(); it.hasNext();) {//检查与顶点v
				var e:Edge = (Edge)it.getNext();//通过边e = (v, w)
				var w:Vertex = (Vertex)e.getVPosInV(1).getElem();//相联的每一顶点w
				var	weight:int = e.getInfo() as int;//根据边(v, w)的权重
				if (w.getDistance() > weight) {//取原距离与新距离中的小者
					w.setDistance(weight);
					w.setBFSParent(v);
				}
			}
		}
	}
	}
}